﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using Easy.Shared.Argument;

namespace Easy.Cloud.Communication.Sms.Core
{
    public static class SmsServiceCollectionExtensions
    {
        /// <summary>
        /// Adds the easycaching.
        /// </summary>
        /// <returns>The easy caching.</returns>
        /// <param name="services">Services.</param>
        /// <param name="setupAction">Setup action.</param>
        public static IServiceCollection AddEasyCloudCommunicationSms(this IServiceCollection services, Action<SmsOptions> setupAction)
        {
            ArgumentCheck.NotNull(setupAction, nameof(setupAction));

            var options = new SmsOptions();

            setupAction(options);

            foreach (var serviceExtension in options.Extensions)
            {
                serviceExtension.AddServices(services);
            }

            services.AddSingleton(options);

            return services;
        }
    }
}
